<template>
  <div id="app">
    <div id="layout">
      <!-- 头部 -->
      <Header />

      <!-- 侧边栏 -->
      <div style="display: flex">
        <Aside />
        <router-view style="flex: 1" />
      </div>

      <!-- 内容 -->
    </div>
  </div>
</template>

<script>
import Header from "@/components/Header.vue";
import Aside from "@/components/Aside.vue";
import jwt_decode from "jwt-decode";
export default {
  name: "login",
  components: {
    Header,
    Aside,
  },
  created() {
    if (localStorage.FundToken) {
      const decode = jwt_decode(localStorage.FundToken);
      // console.log(decode)
      //token存储到vuex中
      this.$store.dispatch("setAutnenticated", !this.isEmpty(decode));
      this.$store.dispatch("setUser", decode);
    }
  },
  methods: {
    //传递值空，返回真，值不为空，返回假
    isEmpty(value) {
      return (
        value === undefined ||
        value === null ||
        (typeof value === "object" && Object.keys(value).length === 0) ||
        (typeof value === "string" && value.trim().length === 0)
      );
    },
  },
};
</script>
<style lang="less">
</style>
